﻿using System;
using System.Collections.Generic;
using System.Data.SQLite;
using System.Linq;
using System.Text;
using _4m.models;
using _4m.utils;

namespace _4m.services
{
    public class OnWeekDao
    {
        private string connStr;

        public OnWeekDao(string connStr)
        {
            this.connStr = connStr;
        }

        /// <summary>
        /// 在表OnWeek创建一个新的记录
        /// </summary>
        /// <param name="onWeekTable"></param>
        /// <returns></returns>
        public int CreateNewRecord(OnWeekTable onWeekTable)
        {
            int count = 0;
            var parameters = new SQLiteParameter[]
                                            {
                                                new SQLiteParameter("@year", onWeekTable.Year),
                                                new SQLiteParameter("@week", onWeekTable.Week),
                                                new SQLiteParameter("@sickness_name", onWeekTable.SicknessName),
                                                new SQLiteParameter("@sickness_num", onWeekTable.SicknessNum),
                                                new SQLiteParameter("@dead_num", onWeekTable.DeadNum)
                                            };
            var sqLiteUtils = new SQLiteUtils();
            count = sqLiteUtils.ExecuteUpdate(SQLConstants.InsertTableOnWeek, parameters, this.connStr);
            return count;
        }
    }
}
